#include <bits/stdc++.h>
#define lb lower_bound
#define ub upper_bound
#define dbl double
using namespace std;
const int maxn = 1e5+5;

int n, m, l, uv;
int d[maxn], v[maxn], a[maxn], p[maxn];

int read(){
	int x = 0, f = 1;
	char c = getchar();
	while (!isdigit(c)){
		if (c == '-') f = -1;
		c = getchar();
	}
	while (isdigit(c)){
		x = x * 10 + (c - '0');
		c = getchar();
	}
	return x * f;
}

void solve(){
	scanf("%d %d %d %d", &n, &m, &l, &uv);
	for (int i = 0; i < n; i++) scanf("%d %d %d", d+i, v+i, a+i);
	for (int i = 0; i < m; i++) scanf("%d", p+i);
	vector<pair<int, int>> k(n+5);
	for (int i = 0; i < n; i++){
		if (a[i] != 0){
			k[i].first = k[i].second = -1;
			for (int j = 0; j < m; j++){
				if (p[j] < d[i]) continue;
				if (sqrt(v[i] * v[i] + 2 * a[i] * (p[j] - d[i])) > uv){
					if (k[i].first == -1) k[i].first = j;
					k[i].second = max(k[i].second, j);
				}
			}
		}else{
			if (v[i] > uv && p[m-1] >= d[i]){
				k[i].first = lb(p, p+m, d[i]) - p;
				k[i].second = m-1;
			}else k[i].first = k[i].second = -1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) if (~k[i].first) ans++;
	printf("%d ", ans);
	sort(k.begin(), k.begin()+n, [](pair<int, int> l, pair<int, int> r){
		return l.second < r.second;
	});
	int now = -1; ans = 0;
	for (int i = 0; i < n; i++){
		if (k[i].first == -1) continue;
		if (now >= k[i].first) continue;
		ans++;
		now = k[i].second;
	}
	ans = m - ans;
	printf("%d\n", ans);
}

int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	int T; scanf("%d", &T);
	while (T--) solve();
	return 0;
}
